package com.hema.auction.utils;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.hema.auction.R;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 描述:
 * 作者:john
 */
public class GlideUtils {

    public static void load(Context context, String url, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.diskCacheStrategy(DiskCacheStrategy.ALL);
        options.placeholder(R.drawable.ic_defaul_image);
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    public static void load(Context context, int resId, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.diskCacheStrategy(DiskCacheStrategy.ALL);
        options.placeholder(R.drawable.ic_defaul_image);
        Glide.with(context).load(resId).apply(options).into(imageView);
    }

    public static void loadAd(Context context, String url, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.diskCacheStrategy(DiskCacheStrategy.ALL);
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    public static void loadAvatar(Context context, String url, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.placeholder(R.drawable.ic_avatar_defaul);
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    public static void load(Context context, String url, CircleImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.placeholder(R.drawable.ic_defaul_image);
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    public static void load(Fragment context, String url, CircleImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.placeholder(R.drawable.ic_defaul_image);
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    public static void load(Fragment context, String url, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.placeholder(R.drawable.ic_defaul_image);
        Glide.with(context).load(url).apply(options).into(imageView);
    }
}
